Skip to content

Conversation

@steffyP
Copy link
Member

@steffyP steffyP commented Jan 27, 2026

As currently the API for ephemeral instances is known to be unstable, this PR aims to make to retry failing API calls and to capture additional logs in case of failure cases.
This way it will be easier to pinpoint issues in the future.

Example logs:

...
curl command failed while fetching instances. Response: {"error": true, "message": "compute.general_error"}
Command failed with exit code 1. Retrying in 5 seconds... (1/5)
Creating preview environment ...
Created preview environment with endpoint URL: https://ls-4ra30eqlofl88.sandbox.localstack.cloud/
...
Fetching logs for preview-localstack-setup-localstack-61 ...
Instance is not ready yet, waiting for 'Ready.' message in logs...
Command failed with exit code 1. Retrying in 5 seconds... (1/5)
preview-localstack-setup-localstack-61 logs:
Localstack extensions installer: installing extensions defined EXTENSIONS_AUTO_INSTALL
....

changes:

  • retry failing API call up to 5 times, with a 5 second waiting time in between (no guarantee this is enough, but it was sufficient for our CI and we have the logs for debugging issues)
  • log details (e.g. retry, the actual response)
  • added a helper script that will be loaded so that we can reuse the function
  • added additional check to make sure that logs are successfully retrieved

Suggested future work (once the API is stable):

  • rather use the localstack CLI than hardcoding the API calls, as any changes to the API will need changes to the action as well
    • As @lukqw pointed out the CLI may not have the capabilities of handling ENVs that have been set (regarding autoloading of pods, extensions etc).
  • add more tests, e.g. some attributes are currently not tested or verified: auto-load-pod, ci-project

@github-actions
Copy link

github-actions bot commented Jan 27, 2026

The ephemeral instance for the application preview has been shut down

@steffyP steffyP changed the title test retry loops to create ephemeral instances add retries for ephemeral instance api calls Jan 29, 2026
Comment on lines +3 to +6
pull_request:
paths-ignore:
- ./*.md
- LICENSE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing the workflow_dispatch that I added in a previous PR, as it doesn't make sense with the logic that the ephemeral instances are currently following (e.g. searching for the PR number and adding comment to the PR)

description: 'LocalStack API key used to access the platform api'
required: true
description: 'LocalStack Auth Token used to access the platform api'
required: false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the localstack-api-key is not documented, neither is it required or currently used in our own CI test. It is a fallback in case the LOCALSTACK_AUTH_TOKEN and LOCALSTACK_API_KEY are not set

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a good point! That's maybe something to revisit in the future. The term is outdated (we only have auth tokens now) and it seems a bit confusing to configure...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to add some more context here:
When someone tries to call the ephemeral instance API we require them to be authenticated.
Since the CI integration cannot provide email/password, we instead authenticate through an auth token.

The easiest way to do that is to use a ls-api-key auth header in combination with a auth token.
We could also switch to the Authorization: header in combination with an auth token, but on the backend we do not expect a plain text token in combination with that header. Happy to share more details here offline.

We could also rename the input variable and still rely on the ls-api-key header FWIW, since we have backwards compatibility.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

following our offline discussion to have a paper-trail here:
there was a misunderstanding: we are not questioning the ls-api-key usage and we know we need to provide a auth-token/key for the request.

The initial comment is really just about the input parameter localstack-api-key for this workflow, that is used for setting the ls-api-key but only as a "last resort fallback" e.g. when the ENVs are not set.
e.g.

AUTH_HEADER="ls-api-key: ${LOCALSTACK_AUTH_TOKEN:-${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}}"

Therefore, I changed the input to required: false for the workflow.

@steffyP steffyP marked this pull request as ready for review January 29, 2026 17:34
@steffyP steffyP requested a review from alexrashed January 29, 2026 17:34
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for fixing the usage of ephemeral instances by implementing the retry logic!
From my perspective this is looking great. I think there is potential to move this to the CLI and reuse it here in the future, but that would definitely be out of scope for this PR!

Given that @lukqw is the expert on ephemeral instances and also has contributed to this feature in the action in the past, I think it might be good to maybe also get a quick review from you as well? 🙏🏽

description: 'LocalStack API key used to access the platform api'
required: true
description: 'LocalStack Auth Token used to access the platform api'
required: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a good point! That's maybe something to revisit in the future. The term is outdated (we only have auth tokens now) and it seems a bit confusing to configure...

# retry() function: Retries a given command up to 'retries' times with a 'wait' interval.
# Usage: retry <command>
# Example: retry my_api_call_function
retry() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukqw I think this is where your input would really be valuable. Is this retry mechanism what you would expect a client to do if they get a failure response from the ephemeral instance API?
This effectively would be a classic retry machanism, 5 retries, 5 seconds constant backoff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping! I believe the approach here would be good enough to bridge the problem we currently have in our backend integration. 👌

I suppose an even safer approach would be to roll with some exponential back-off mechanism, but that could also be overkill / not necessary at the current stage.

Thanks a lot for diving into this @steffyP! 🙏 🚀

Copy link
Member

@lukqw lukqw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review folks! I was wrapped up in other topics unfortunately 🦥

Praise: Thanks a lot @steffyP for providing such a neat abstract retry function we can use to make our CI integration with ephemeral instances stabler 💪 🚀

# retry() function: Retries a given command up to 'retries' times with a 'wait' interval.
# Usage: retry <command>
# Example: retry my_api_call_function
retry() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping! I believe the approach here would be good enough to bridge the problem we currently have in our backend integration. 👌

I suppose an even safer approach would be to roll with some exponential back-off mechanism, but that could also be overkill / not necessary at the current stage.

Thanks a lot for diving into this @steffyP! 🙏 🚀

description: 'LocalStack API key used to access the platform api'
required: true
description: 'LocalStack Auth Token used to access the platform api'
required: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to add some more context here:
When someone tries to call the ephemeral instance API we require them to be authenticated.
Since the CI integration cannot provide email/password, we instead authenticate through an auth token.

The easiest way to do that is to use a ls-api-key auth header in combination with a auth token.
We could also switch to the Authorization: header in combination with an auth token, but on the backend we do not expect a plain text token in combination with that header. Happy to share more details here offline.

We could also rename the input variable and still rely on the ls-api-key header FWIW, since we have backwards compatibility.

@steffyP steffyP merged commit 7c4d408 into main Feb 4, 2026
6 checks passed
@steffyP steffyP deleted the fix-ephemeral branch February 4, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants